﻿<%@ include file="/WEB-INF/jsp/include.jsp" %>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #F8F9FA;
}
-->
</style>

<link href="<%=request.getContextPath()%>/images/skin.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/images/fox.css" rel="stylesheet" type="text/css" />
<script src="<%=request.getContextPath()%>/js/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/doorscrm/orders/add_orders_loop.js" type="text/javascript"></script>
<style type="text/css">
<!--
.STYLE1 {font-weight: bold}
-->
</style>
<body>
<form name="form1" method="post" id="form1" action="">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<input name="pid" type="hidden" id="pid" value="${orderid}"/>
	<input name="productno" type="hidden" id="productno" value=""/>
	<input name="type" type="hidden" id="type" value="${type}"/>
  <tr>
    <td width="17" height="29" valign="top" background="<%=request.getContextPath()%>/images/mail_leftbg.gif"><img src="<%=request.getContextPath()%>/images/left-top-right.gif" width="17" height="29" /></td>
    <td width="935" height="29" valign="top" background="<%=request.getContextPath()%>/images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">木门下单</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="<%=request.getContextPath()%>/images/mail_rightbg.gif"><img src="<%=request.getContextPath()%>/images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="<%=request.getContextPath()%>/images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="80%" height="138" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td>
            	 <ul class="navt">
        	 		<c:forEach items="${ProductType_list}" var="pt" >
                <li><a <c:if test="${type==pt.id}"> class="navdq"</c:if> <c:if test="${type!=pt.id}"> class="navdqt"</c:if> href="<%=request.getContextPath()%>/redirect/addorderdetails/${orderid}/${pt.id}">新增${pt.name}</a></li>
               </c:forEach>

            </ul>
            	</td>
          </tr>
          <tr>
            <td><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
              <tr>
                <td class="left_bt2"><div align="center">新增空门套信息</div></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td>
                <table width="100%" height="90" border="0" cellpadding="0" cellspacing="0">
                  <tr >
                    <td colspan="11" align="center" bgcolor="#f2f2f2" class="tda"><div align="left"><strong>基础信息</strong></div></td>
                    </tr>
                  <tr>
                    <td width="13%" rowspan="3" align="center" class="tda"><strong>基本信息</strong></td>
                    <td colspan="2" align="center" class="tda">空套类型</td>
                    <td width="11%" align="center" class="tda"><div align="left"><span class="left_txt">
                     <select name="sery" id="sery" onChange="productsery_onchange()">
                       <option value="-1">请选择</option>
                    </select>
                    </span></div></td>
                    <td width="12%" align="center" class="tda"><span class="left_txt">
                      <select name="productid" id="productid" onChange="productid_onchange()">
                      	 <option value="-1">请选择</option>
                    	</select>
                    </span></td>
                    <td width="5%" align="center" class="tda">单价</td>
                    <td width="14%" align="center" class="tda"><div align="left">
                      <input type="text" style="color=red" name="single_price" id="single_price" value="0" size="10" class="button01" />
                    元</div></td>
                    <td width="7%" align="center" class="tda">颜色</td>
                    <td colspan="2" class="tda"><input type="text" style="color=red" name="colour" id="colour" value="" size="10" class="button01" /></td>
                    <td width="11%" rowspan="4"  align="center" class="tda"><input type="button" name="button2" onclick="calculate_func_loop()" id="button2" value="计算"></td>
                  </tr>
                
                  <tr>
                    <td colspan="2" align="center" class="tda">面板材料</td>
                    <td colspan="2" align="center" class="tda"><div align="left"><span class="left_txt">
                     <select name="facetableid" id="facetableid"  onChange="optation_onchange(1)" >
                      <option value="-1">请选择</option>
                       <c:forEach items="${ProductTable_list_1}" var="pt" >
                         <option value="${pt.id}">${pt.name}</option>
                       </c:forEach>
                       <option value="0">其它</option>
                    </select>
                    </span></div></td>
                    <td colspan="2" align="center" class="tda"><div align="left" style="display:none;" id="facetable_qt_id_1">
                      &nbsp;<input type="text" style="color=red" name="facetable" id="facetable"  value="" size="15" class="button01" />
                    </div></td>
                    <td colspan="3" align="center" class="tda"><div align="left">&nbsp;</div></td>
                  </tr>
                  <tr>
                    <td colspan="2" align="center" class="tda">线条类型</td>
                    <td colspan="2" align="center" class="tda"><div align="left"><span class="left_txt">
                     <select name="doorslineid" id="doorslineid" onChange="optation_onchange(2)">
                        <option value="-1">请选择</option>
                        <c:forEach items="${ProductTable_list_2}" var="pt" >
                         <option value="${pt.id}">${pt.name}</option>
                       </c:forEach>
                       <option value="0">其它</option>
                    </select>
                    </span></div></td>
                    <td colspan="2" align="center" class="tda"><div align="left" style="display:none;" id="doorsline_qt_id_1">
                      &nbsp;<input type="text" style="color=red" name="doorsline" id="doorsline" value="" size="15" class="button01" />
                    </div></td>
                    <td colspan="3" align="center" class="tda"><div align="left">&nbsp;</div></td>
                    </tr>
                  <tr>
                    <td  align="center" bgcolor="#f2f2f2" class="tda"><strong>原始信息</strong></td>
                    <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda">高</td>
                    <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda"><div align="left">
                      <input type="text" style="color=red" name="originalhigh" id="originalhigh" value="" size="10" class="button01" />
                    </div></td>
                    <td align="center" bgcolor="#f2f2f2" class="tda">宽</td>
                    <td align="center" bgcolor="#f2f2f2" class="tda"><div align="left">
                      <input type="text" style="color=red" name="originalwidth" id="originalwidth" value="" size="10" class="button01" />
                    </div></td>
                    <td align="center" bgcolor="#f2f2f2" class="tda">厚</td>
                    <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda"><div align="left">
                      <input type="text" style="color=red" name="originallength" id="originallength" value="" size="10" class="button01" />
                    </div></td>
                    </tr>
                  
                   <tr>
                     <td colspan="10" align="center"  class="tda"><div align="left" class="STYLE1">
                       <DIV align="left">以下系统自动计算 </DIV>
                     </div></td>
                     <td  align="center" class="tda">&nbsp;</td>
                   </tr>
                   <tr>
                       
                       <td align="center"  class="tda"><strong>门线净尺寸</strong></td>
                       <td colspan="2" align="center"  class="tda">高</td>
                       <td colspan="2" align="center"  class="tda">
                         <div align="left">
                           <input type="text" style="color=red" name="confirmhigh" id="confirmhigh" value="" size="10" class="button01" />
                       </div></td>
                       <td align="center"  class="tda">宽</td>
                       <td align="center"  class="tda">
                         <div align="left">
                           <input type="text" style="color=red" name="confirmwidth" id="confirmwidth" value="" size="10" class="button01" />
                       </div></td>
                       <td align="center"  class="tda">厚</td>
                       <td colspan="2" align="center"  class="tda">
                         <div align="left">
                           <input type="text" style="color=red" name="confirmlength" id="confirmlength" value="" size="10" class="button01" />
                       </div></td>
                       <td  align="center" class="tda">&nbsp;</td>
                   </tr>
                   <tr>
                     <td rowspan="2" align="center" bgcolor="#f2f2f2" class="tda"><strong>门线条尺寸</strong></td>
                     <td width="5%" align="center" bgcolor="#f2f2f2" class="tda">线条1 </td>
                     <td width="6%" align="center" bgcolor="#f2f2f2" class="tda">长</td>
                     <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda"><div align="left">
                       <input type="text" style="color=red" name="doorslinelength" id="doorslinelength" value="" size="10" class="button01" />
                     </div></td>
                     <td align="center" bgcolor="#f2f2f2" class="tda">数量</td>
                     <td align="center" bgcolor="#f2f2f2" class="tda"><div align="left">
                       <input type="text" style="color=red" name="doorslinenum" id="doorslinenum" value="" size="10" class="button01" />
                     </div></td>
                     <td align="center" bgcolor="#f2f2f2" class="tda">&nbsp;</td>
                     <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda">&nbsp;</td>
                     <td  align="center" class="tda">&nbsp;</td>
                   </tr>
                   <tr>
                       <td align="center" bgcolor="#f2f2f2" class="tda">线条2</td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">长</td>
                       <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda">
                         <div align="left">
                           <input type="text" style="color=red" name="doorslinelength2" id="doorslinelength2" value="" size="10" class="button01" />
                       </div></td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">数量</td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">
                         <div align="left">
                           <input type="text" style="color=red" name="doorslinenum2" id="doorslinenum2" value="" size="10" class="button01" />
                       </div></td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">&nbsp;</td>
                       <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda">&nbsp;</td>
                       <td  align="center" class="tda">&nbsp;</td>
                  </tr>
                  <tr>
                    <td align="center" class="tda"><strong>备注：</strong></td>
                    <td colspan="10" class="tda"><span id="sprytextarea1">
                      <label>
                        <textarea name="textarea1" id="textarea1" cols="45" rows="3">&nbsp;</textarea>
                      </label>
                    </span></td>
                    </tr>
                   <tr>
                    <td  align="center" bgcolor="#f2f2f2" class="tda"><strong>总价：</strong></td>
                    <td colspan="10"  align="center" bgcolor="#f2f2f2" class="tda"><div align="left">
                    	 <input type="text" style="color=red" name="price" id="price" value="0" size="10" class="button01" />
                    元
                    	</div></td>
                    </tr>
                 
                  <tr>
                    <td colspan="11" align="center" class="tda">
                      <input type="button" onclick="go_submit()" name="button" id="button" value="确定并下单">    
                      <input type="button" name="button" onClick="re_back()" id="button" value="返回列表">                    </td>
                    </tr>
                  <tr>
                    <td>&nbsp;&nbsp;</td>
                    <td colspan="2">&nbsp;</td>
                    <td colspan="2">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;&nbsp;</td>
                    <td>&nbsp;</td>
                    <td width="1%">&nbsp;</td>
                    <td width="15%">&nbsp;</td>
                  </tr>
                </table>             </td>
          </tr>
          
        </table>
          </td>
      </tr>
    </table></td>
    <td background="<%=request.getContextPath()%>/images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" background="<%=request.getContextPath()%>/images/mail_leftbg.gif"><img src="<%=request.getContextPath()%>/images/buttom_left2.gif" width="17" height="17" /></td>
      <td height="17" valign="top" background="<%=request.getContextPath()%>/images/buttom_bgs.gif"><img src="<%=request.getContextPath()%>/images/buttom_bgs.gif" width="17" height="17" /></td>
    <td background="<%=request.getContextPath()%>/images/mail_rightbg.gif"><img src="<%=request.getContextPath()%>/images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>
</form>
</body>
<script type="text/javascript">
jQuery(function($) {
		var msg="${msg}";
		if(msg!="") alert(msg);
		producttype_onchange();
	});


//产品系列
function productsery_onchange(){
	var t=$('#sery').val();
	$.getJSON("<%=syscontextPath %>/product/findProductList/"+t,
	    function(data){
	    	$("#productid").empty();
	    	$("#productid").append("<option value='-1'>请选择</option>");
				 $.each(data, function(k, v) {
				 			 var v_id=v.id;
							 $("#productid").append("<option value='"+v_id+"'>"+v.productno+"</option>");
							 var p_a=new Array();
							 p_a[0]=v_id;
							 p_a[1]=v.price;
							 product_arr[k]=p_a;
					});
			}
	);
	
}

//产品类型
function producttype_onchange(){
		$.getJSON("<%=syscontextPath %>/basicinfo/findProductSeryList/${type}",
		    function(data){
		    		$("#sery").empty();
		    		$("#sery").append("<option value='-1'>请选择</option>");
					  $.each(data, function(k, v) {
								$("#sery").append("<option value='"+v.id+"'>"+v.name+"</option>");
						});
				}
		);
}
//计算尺寸
function calculate_func_loop(){
	
	if (checkform()) {
		$.post('<%=syscontextPath %>/calculate/loop', 
			        { productid:$('#productid').val(),
			        	facetableid:$('#facetableid').val(),facetable_qt_price:$('#facetable_qt_price').val(),
			        	doorslineid:$('#doorslineid').val(),doorsline_qt_price:$('#doorsline_qt_price').val(),
			        	originalhigh:$('#originalhigh').val(),originalwidth:$('#originalwidth').val(),
			        	originallength:$('#originallength').val(),single_price:$('#single_price').val()
			        },function(data) {
			         	
			         	  //先清空
				  $('#doorslinelength').val('');
					$('#doorslinenum').val('');  
					$('#doorslinelength2').val('');
					$('#doorslinenum2').val('');  
					$('#confirmhigh').val('');  
					$('#confirmwidth').val('');  
					$('#confirmlength').val(''); 
 
				  $('#price').val('');	
				
				   //设值
				  $('#doorslinelength').val(data.doorslinelength);
					$('#doorslinenum').val(data.doorslinenum);  
					
					$('#doorslinelength2').val(data.doorslinelength2);
					$('#doorslinenum2').val(data.doorslinenum2);  
			
					$('#confirmhigh').val(data.originalhigh);  
					$('#confirmwidth').val(data.originalwidth);  
					$('#confirmlength').val(data.originallength); 
					 
				  $('#price').val(data.price);	
			         	
			         	
			         	
			         	
			         	},"json");
			         	
			  }
	
}
//提交
function go_submit(){
		if (checkform()&&form_submit()) {	 
				//序 列化表格元素 (类似 '.serialize()' 方法) 返回 JSON 数据结构数据
			  var	content = $("#form1").serializeArray();
				$.post('<%=syscontextPath %>/orders/addOrderDetail/${orderid}', content, function(data) {
					if (data.flag) {
						alert("保存成功！");
						if(confirm("需要继续新增吗？")){
							location.href="<%=request.getContextPath()%>/redirect/addorderdetails/${orderid}/2";
						}else{
							 location.href="<%=syscontextPath %>/orders/findOrderById/${orderid}";
						}
					} else {
						alert("保存失败！");
						
					}
				},"json");
	}
}
//返回
function re_back(){
	if(confirm("确认返回订单列表？"))
	location.href="<%=syscontextPath %>/orders/findOrderById/${orderid}";
}
</script>